<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form id="login" action="">
        <input type="text" name="username"><br>
        <input type="password" name="password"><br>
        <button class="btn">提交</button>
    </form>
</body>
<script>
    const formAction = document.querySelector('#login')
    const btn = document.querySelector('.btn')
    btn.addEventListener('click', (e) => {
        e.preventDefault()
        localStorage.setItem('username', formAction.username.value)
        localStorage.setItem('password', formAction.password.value)
    })
    const username = localStorage.getItem('username')
    if (username) {
        formAction.username.value = username
    }

    localStorage.setItem('555', 123)
    const str = localStorage.getItem('555')
    console.log(str, Object.prototype.toString.call(localStorage.getItem('555')));
    const num = Number(str)
    console.log(num,typeof num);

    console.log(localStorage.length);
</script>

</html>